//
//  ZhBaseController.swift
//  Uber
//
//  Created by 朱 桓 on 16/1/6.
//  Copyright © 2016年 zhu.huan. All rights reserved.
//

import UIKit

class ZhBaseController: UIViewController {
    
    var activity:FxActivity?

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    private func showActivityInView(view:UIView) -> FxActivity
    {
        let _activity = FxActivityIndicator(view: view)
        _activity.frame = view.bounds
        _activity.labelText = ""
        
        view.addSubview(_activity)
        
        return _activity
    }
    
    /**
    *显示等待状态框
    *
    *@param tipMessage 提示信息
    *@param autoHide 是否自动隐藏
    *@param afterDelay 是否延迟显示
    */
    func showIndicator(tipMessage: String?, autoHide: Bool, afterDelay: Bool)
    {
        if activity == nil {
            activity = showActivityInView(self.view)
        }
        
        if tipMessage != nil {
            activity?.labelText = tipMessage
            activity?.show(false)
        }
        
        if autoHide && activity?.alpha >= 1.0 {
            if afterDelay {
                activity?.hide(true, afterDelay: 1.0)
            }
            else {
                activity?.hide(true)
            }
        }
    }
    
    func hideIndicator()
    {
        activity?.hide(true)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

}
